/*
package com.geping.etl.common.service.kettle.impl;

import com.alibaba.fastjson.JSONObject;
import com.geping.etl.common.dto.KettleRunResultDto;
import com.geping.etl.common.service.kettle.RunPathService;
import com.geping.etl.common.service.kettle.RunPathServiceDispatcher;
import lombok.extern.slf4j.Slf4j;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.springframework.stereotype.Service;
*/
/**//*

*/
/***
 *  支持kettle ktr脚本
 * @author liang.xu
 * @date 2021.7.3
 *//*

@Service
@Slf4j
public class KtrRunPathServiceImpl extends RunPathServiceDispatcher implements RunPathService {


    @Override
    public KettleRunResultDto runPath(String pathname) {
        try {
            KettleEnvironment.init();
            TransMeta tranMeta  = new TransMeta(pathname);
            Trans trans = new Trans(tranMeta);
            // 向Job 脚本传递参数，脚本中获取参数值：${参数名}
            // job.setVariable(paraname, paravalue);
            trans.execute(null);
            trans.waitUntilFinished();
            log.info("result:{}",trans.getResult().getResult());
            if (trans.getErrors() > 0) {
                log.error("执行跑批失败");
                return KettleRunResultDto.error("执行跑批失败!");
            }else{
                log.error("执行跑批成功");
            }
        } catch (Exception e) {
           log.error("执行kjb发生错误-->",e);
            return KettleRunResultDto.error("执行kjb发生错误!");
        }
        return KettleRunResultDto.success("执行跑批成功!");
    }

    @Override
    public boolean canRun(String pathname) {
        return pathname.endsWith(".ktr");
    }

    public static void main(String[] args) {
        KtrRunPathServiceImpl kjbRunPathServiceImpl=new KtrRunPathServiceImpl();
        KettleRunResultDto kettleRunResultDto=kjbRunPathServiceImpl.runPath("D:\\20210329_2\\DEV\\rs\\test.ktr");
        System.out.println(JSONObject.toJSONString(kettleRunResultDto));

    }
}*/
